Use case: User application in most basic use case ¶
This use case shows a minimal HAL initialization flow and tick/time-base usage.
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
int main(void)
{
HAL_Init();
/*
...
*/
/* Update Tick frequency */
if (HAL_SetTickFreq(HAL_TICK_FREQ_10KHZ) != HAL_OK)
{
return HAL_ERROR;
}
/* Update Tick interrupt priority */
if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
{
return HAL_ERROR;
}
/* Get Tick */
uint32_t tick1 = HAL_GetTick();
/* Delay */
HAL_Delay(1000);
/* Get Tick */
uint32_t tick2 = HAL_GetTick();
/* Suspend Tick */
HAL_SuspendTick();
/* Resume Tick */
HAL_ResumeTick();
return HAL_OK;
}
|
int main(void)
{
HAL_Init();
/*
...
*/
/* Update Tick frequency and interrupt priority */
if (HAL_InitTick(HAL_TICK_FREQ_10KHZ, TICK_INT_PRIORITY) != HAL_OK)
{
return HAL_ERROR;
}
/* Get Tick */
uint32_t tick1 = HAL_GetTick();
/* Delay */
HAL_Delay(1000);
/* Get Tick */
uint32_t tick2 = HAL_GetTick();
/* Suspend Tick */
HAL_SuspendTick();
/* Resume Tick */
HAL_ResumeTick();
return HAL_OK;
}
|
Key changes ¶
HAL2 merges tick frequency and tick interrupt priority configuration into
HAL_InitTick(hal_tick_freq_t tick_freq, uint32_t tick_priority).HAL1 uses separate calls (for example
HAL_SetTickFreq()andHAL_InitTick(uint32_t TickPriority)) for tick configuration.

